import React from 'react';
import ReactDOM from 'react-dom';


class Father extends React.Component { 
  state = { 
    num: 1,
    age:100
  }
  add = () => {
    this.setState({
      num: this.state.num + 1
    })
  }
  
  render () {
    return (<div>父组件：{this.state.num}
      <Son age={this.state.age}/> <button onClick={this.add}>+1</button></div>)
  }
} 
class Son extends React.PureComponent { 
  state = { 
    num: 1
  }
  render () {
    console.log(Date.now(), '子组件render',this.props)
    return (<div>子组件 {this.props.age}</div>)
  }
} 


ReactDOM.render(<div>
  <Father/>
</div>, 
document.getElementById('root')) 
